package com.zprmb.udzt.adapter;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zprmb.udzt.R;
import com.zprmb.udzt.bean.DexterityShouyi_Bean;
import com.zprmb.udzt.util.TimeUtils;

public class DexterityShouyiAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<DexterityShouyi_Bean> list;
	DecimalFormat df = new DecimalFormat("###0.00");

	public DexterityShouyiAdapter(Context context,
			ArrayList<DexterityShouyi_Bean> list) {
		this.context = context;
		this.list = list;
	}

	public int getCount() {
		return list.size();
	}

	public Object getItem(int arg0) {
		return arg0;
	}

	public long getItemId(int arg0) {
		return arg0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		DexterityShouyi_Bean db = list.get(position);
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = View.inflate(context,
					R.layout.item_v4_dextertiy_shouyi, null);
			holder.tv_v4_item_dexterity_qiri_time = (TextView) convertView
					.findViewById(R.id.tv_v4_item_dexterity_qiri_time);
			holder.tv_v4_item_dexterity_qiri_today = (TextView) convertView
					.findViewById(R.id.tv_v4_item_dexterity_qiri_today);
			holder.tv_v4_item_dexterity_qiri_leiji = (TextView) convertView
					.findViewById(R.id.tv_v4_item_dexterity_qiri_leiji);
			holder.tv_v4_item_dexterity_qiri_hold = (TextView) convertView
					.findViewById(R.id.tv_v4_item_dexterity_qiri_hold);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tv_v4_item_dexterity_qiri_time.setText(TimeUtils
				.formatTime(new Date(Long.valueOf(db.recordTime))));
		holder.tv_v4_item_dexterity_qiri_today.setText(df.format(Double
				.parseDouble(db.amount)));
		holder.tv_v4_item_dexterity_qiri_leiji.setText(df.format(Double
				.parseDouble(db.accumulateProfit)));
		holder.tv_v4_item_dexterity_qiri_hold.setText(df.format(Double
				.parseDouble(db.holdAmount)));
		return convertView;
	}

	public class ViewHolder {
		TextView tv_v4_item_dexterity_qiri_time;
		TextView tv_v4_item_dexterity_qiri_today;
		TextView tv_v4_item_dexterity_qiri_leiji;
		TextView tv_v4_item_dexterity_qiri_hold;
	}

}
